import type {
  GetCodeData,
  GetCodeParams,
  LoginCodeParams,
  LoginData,
  User,
  UserData,
} from '@/types/user'
import request from '@/utils/request'

export const LoaginAPI = (data: User) => {
  return request.post<null, LoginData>('/login/password', data)
}

/**
 * 发送验证码
 */
export const getCodeApi = (params: GetCodeParams) => {
  // get 方法的参数需要通过 params 来传递
  return request.get<null, GetCodeData>('/code', { params })
}

/**
 * 用户登录接口（短信验证码方式）
 */
export const loginByMobileApi = (data: LoginCodeParams) => {
  return request.post<null, LoginData>('/login', data)
}

export const getuserInfoApi = () => {
  return request.get<null, UserData>('/patient/myUser')
}
